using System;
using Glue.Internals.Nulls;

namespace Glue.Internals
{
    internal class MemberRepresentingBaseObject : IRepresentBaseObject, INestedMember
    {
        private readonly Type type;

        /// <summary>
        /// Should only be used by ObjectMemberFactory
        /// </summary>
        internal MemberRepresentingBaseObject(Type type)
        {
            this.type = type;
        }

        public string Name
        {
            get { return "Base"; }
        }

        public Type MemberType
        {
            get { return type; }
        }

        public bool CanGetValues
        {
            get { return true; }
        }

        public bool CanSetValues
        {
            get { return true; }
        }

        public object InvokeGet(object toInvokeOn)
        {
            return toInvokeOn;
        }

        public void InvokeSet(object toInvokeOn, object toSet)
        {
            // No need, the mapper has already done this.
        }

        public Maybe <IHoldDifferentBaseMemberName> GetParentProperty()
        {
            return Maybe<IHoldDifferentBaseMemberName>.Nothing();
        }

        public bool CanMapFrom(object thisObject) {return true;}

        public bool IsNested()
        {
            return true;
        }
    }
}